#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main() {
    char symbol;
    int N;
    auto buf = std::string();  // line buffer

    std::getline(std::cin, buf);  // read whole first line
    std::istringstream iss(buf);
    iss >> symbol;
    iss >> N;

    // Allocate the memory & read the pattern
    
    std::vector<std::string> pattern;
    pattern.reserve(N);
    
    for (int i = 0; i < N; ++i) {
        pattern.reserve(N);
        std::getline(std::cin, buf);
        pattern.push_back(buf);
    }

    // Allocate new pattern's memory

    auto new_pattern = std::vector<std::string>(N);
    for (auto & line : new_pattern) { line.resize(N); }

    // Check whether the pattern is the same or not when rotated 180 degrees

    bool is_rotated_same = true;

    for (auto i = 0; i < N; ++i) {
        for (auto j = 0; j < N; ++j) {
            auto ch = pattern[N - 1 - i][N - 1 - j];
            // if (ch != pattern[i][j]) { is_reversed_same = false; }
            is_rotated_same = is_rotated_same && (ch == pattern[i][j]);
            new_pattern[i][j] = ch;
        }
    }

    // Do ouput task

    if (is_rotated_same) { std::cout << "bu yong dao le" "\n"; }
    
    for (auto const & line : new_pattern) {
        std::for_each(line.begin(), line.end(), 
            [c=symbol](auto ch){
                if (ch == ' ') { std::cout << ' '; }
                else { std::cout << c; }
            });
        std::cout << "\n";
    }
}
